﻿Option Explicit On
Option Strict On

Namespace Framework.RS232

    ''' <summary>
    ''' Contains the parameters used when opening a COM port
    ''' </summary>
    ''' <remarks></remarks>
    Public Class RS232PortParameters

#Region " Private Members "

        Private m_BaudRate As Integer
        Private m_PortName As String
        Private m_DtrEnable As Boolean
        Private m_RtsEnable As Boolean
        Private m_StopBits As IO.Ports.StopBits
        Private m_DataBits As Integer
        Private m_Handshake As IO.Ports.Handshake
        Private m_Parity As IO.Ports.Parity

#End Region

#Region " Constructors "

        ''' <summary>
        ''' 
        ''' </summary>
        ''' <param name="BaudRate"></param>
        ''' <param name="PortName"></param>
        ''' <param name="DtrEnable"></param>
        ''' <param name="RtsEnable"></param>
        ''' <param name="StopBits"></param>
        ''' <param name="DataBits"></param>
        ''' <param name="Handshake"></param>
        ''' <remarks></remarks>
        Public Sub New(ByVal BaudRate As Integer, ByVal PortName As String, ByVal DtrEnable As Boolean, ByVal RtsEnable As Boolean, ByVal StopBits As IO.Ports.StopBits, ByVal DataBits As Integer, ByVal Handshake As IO.Ports.Handshake, ByVal Parity As IO.Ports.Parity)
            m_BaudRate = BaudRate
            m_PortName = PortName
            m_DtrEnable = DtrEnable
            m_RtsEnable = RtsEnable
            m_StopBits = StopBits
            m_DataBits = DataBits
            m_Handshake = Handshake
            m_Parity = Parity
        End Sub

#End Region

#Region " Public Properties "

        ''' <summary>
        ''' The Baud Rate of the COM Port
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property BaudRate() As Integer
            Get
                Return m_BaudRate
            End Get
            Set(ByVal value As Integer)
                m_BaudRate = value
            End Set
        End Property

        ''' <summary>
        ''' The Name of the COM port
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property PortName() As String
            Get
                Return m_PortName
            End Get
            Set(ByVal value As String)
                m_PortName = value
            End Set
        End Property

        ''' <summary>
        ''' Should the DTR line be enabled
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property DtrEnable() As Boolean
            Get
                Return m_DtrEnable
            End Get
            Set(ByVal value As Boolean)
                m_DtrEnable = value
            End Set
        End Property

        ''' <summary>
        ''' Should the RTS line be enabled
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property RtsEnable() As Boolean
            Get
                Return m_RtsEnable
            End Get
            Set(ByVal value As Boolean)
                m_RtsEnable = value
            End Set
        End Property

        ''' <summary>
        ''' The number of Stop Bits
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property StopBits() As IO.Ports.StopBits
            Get
                Return m_StopBits
            End Get
            Set(ByVal value As IO.Ports.StopBits)
                m_StopBits = value
            End Set
        End Property

        ''' <summary>
        ''' The number of Data Bits
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property DataBits() As Integer
            Get
                Return m_DataBits
            End Get
            Set(ByVal value As Integer)
                m_DataBits = value
            End Set
        End Property

        ''' <summary>
        ''' The Handshake mode of the COM Port
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property Handshake() As IO.Ports.Handshake
            Get
                Return m_Handshake
            End Get
            Set(ByVal value As IO.Ports.Handshake)
                m_Handshake = value
            End Set
        End Property

        ''' <summary>
        ''' The Parity Mode of the COM Port
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property Parity() As IO.Ports.Parity
            Get
                Return m_Parity
            End Get
            Set(ByVal value As IO.Ports.Parity)
                m_Parity = value
            End Set
        End Property

#End Region

    End Class

End Namespace